<template>
	<view class="content" :style="'background: url('+ c_imgPath + 'mine/indexBg.png'+ ') repeat-y 0 0 / 100% auto;'">
		<view class="qiehuan">
			<view v-for="(v,i) in arr" :key="i" @click="getlist(v.id)">
				<view :class="show==v.id?'xzs':'wzs'">{{v.title}}</view>
				<!-- <view class="qiehuan_line" v-if="show==v.id"> </view> -->
			</view>
		</view>
		<!-- 内容 -->
		<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback"
			v-if="showList">
			<view class="coupon">
				<view v-for="(item,index) in aixuanArr" :key="index" class="coupon_item">
					<view class="coupon_item_1">
						<view>{{item.content}}</view>
						<view>{{item.addtime}}</view>
					</view>
					<view class="coupon_r flex_center">
						<text>{{item.change_money}}</text>
					</view>
				</view>
			</view>
		</mescroll-body>
		<view class="code" v-else>
			<view class="code_img">
				<image :src="code_img"></image>
			</view>
			<view class="code_text">{{code_content}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				c_imgPath: 'https://qt.yhemall.com/',
				show: 5,
				aixuanArr: [],
				downOption: {
					auto: false
				},
				arr: [{
					title: '消费奖励',
					id: 5
				}, {
					title: '注册奖励',
					id: 6
				}],
				is_presenter: '',
				showList: true,
				code_img: '',
				code_content: ''

			}
		},
		onLoad(e) {
			this.getdata();
		},
		methods: {
			getlist(v) {
				this.show = v;
				if (v == 6 && this.is_presenter != 1) {
					this.showList = false;
					this.aixuanArr = [];
					return false
				} else {
					this.showList = true;
				}
				this.mescroll.resetUpScroll()
			},
			downCallback() {
				this.getdata();
				this.mescroll.resetUpScroll()
			},
			upCallback(page) {
				this.loadData(page.num);
			},
			getdata() {
				let that = this;
				that.req({
					url: 'user',
					success(res) {
						if (res.status == 1) {
							that.is_presenter = res.data.userinfo.is_presenter;
							uni.setStorageSync('userinfo', res.data.userinfo)
							uni.setStorageSync('jump_appid', res.data.other.jump_appid)
							uni.setStorageSync('wx_link', res.data.other.wx_link)
							uni.setStorageSync('corpid', res.data.other.corpid)
						}
					}
				})
			},
			loadData(pageNo) {
				// 模拟接口
				let that = this;
				that.req({
					url: 'invitation_commission',
					Loading: true,
					data: {
						page: pageNo,
						type: that.show
					},
					success(res) {
						that.mescroll.endByPage(res.data.data.length, res.data.last_page);
						that.code_img = res.data.kf_code;
						that.code_content = res.data.kf_content;
						if (pageNo == 1) {
							that.aixuanArr = res.data.data;
						} else {
							that.aixuanArr = that.aixuanArr.concat(res.data.data);
						}

					}
				})
			},


		}
	}
</script>

<style lang="scss">
	.code {
		padding: 0 30rpx;
		padding-top: 200rpx;
		text-align: center;
		color: #FFFFFF;

		.code_img {
			image {
				width: 300rpx;
				height: 300rpx;
			}
		}
	}


	.qiehuan {
		display: flex;
		/* justify-content: space-between; */
		align-items: center;
		width: 690rpx;
		margin: 0 auto;
		box-sizing: border-box;
		/* font-family: 'zcq'; */
		font-weight: bold;
		overflow-x: scroll;
		margin-top: 30rpx;
	}

	.qiehuan_line {
		margin: -10rpx auto;
		width: 50rpx;
		height: 20rpx;
		border-bottom: 4rpx solid #B07CDD;
		border-radius: 2rpx;
	}


	.qiehuan>view {
		/* flex: 1; */
		// width: 130rpx;
		padding: 0 10rpx;
		height: 58rpx;
		line-height: 58rpx;
		text-align: center;
		margin-right: 24rpx;
		flex-shrink: 0;
	}

	.wzs {
		font-size: 24rpx;
		color: rgba(255, 255, 255, 1);
	}

	.xzs {
		font-size: 28rpx;
		background: linear-gradient(0deg, #B75AFF 0%, #E7CBFF 100%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
	}

	.coupon_r>image {
		width: 32rpx;
		height: 32rpx;
		margin-left: 10rpx;
	}

	.coupon_r {
		font-size: 32rpx;
		/* font-family: 'zcq'; */
		color: #B07CDD;
	}

	.coupon_item_1>view:nth-of-type(2) {
		font-size: 24rpx;
		color: rgba(255, 255, 255, 0.6);
		margin-top: 10rpx;
	}

	.coupon_item_1>view:nth-of-type(1) {
		font-size: 28rpx;
		font-weight: bold;
		color: #FFFFFF;
	}

	.coupon_item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx;
		box-sizing: border-box;
		/* border-bottom: 1rpx solid #EEEEEE; */
		border: 1px solid;
		border-image: linear-gradient(0deg, #5D5868, #92949A) 10 10;
		background: linear-gradient(0deg, #2D2C4A 0%, #48495B 100%);
		margin-bottom: 20rpx;
		border-radius: 10rpx;
	}

	.coupon {
		width: 690rpx;
		margin: 20rpx auto;
		/* background: #11141D;
		box-shadow: 0px 0px 10rpx 0px rgba(150, 255, 254, 0.7);
		padding: 0 30rpx; */
		padding-top: 30rpx;
		box-sizing: border-box;
		/* border-radius: 20rpx; */
	}


	.close {
		text-align: left;
	}

	.close>image {
		width: 48rpx;
		height: 48rpx;
	}

	.head>view {
		flex: 1;
	}

	.head {
		width: 750rpx;
		height: 88rpx;
		padding: 0 20rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		/* font-family: 'zcq'; */
		color: #FFFFFF;
		font-size: 36rpx;
		text-shadow: 0px 0px 10rpx rgba(150, 255, 254, 0.6);
	}

	.header {
		width: 750rpx;
		/* height: 176rpx; */
		padding-bottom: 30rpx;
		background: rgba(0, 0, 0, 0.8);
		font-size: 28rpx;
		color: #333333;
		box-sizing: border-box;
		position: fixed;
		top: 0;
		/* #ifdef MP */
		padding-top: 24rpx;
		/* #endif */
		z-index: 15;
	}

	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}


	.content {
		width: 100vw;
		min-height: 100vh;
		box-sizing: border-box;
		padding-top: 1rpx;
	}
</style>